Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct f-strings in parallel/non-parallel AutoAttack metadata #2550

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

lockwoodar
Copy link
Collaborator

Description

Full Issue Details: #2548

  • Fixes string literals in returned AutoAttack metadata (both parallel and non-parallel) to correctly use f-strings

Fixes #2548

Type of change

Please check all relevant options.

  • Improvement (non-breaking)
  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Testing

  • I utilized the same test that is outlined in Erroneous literal string in AutoAttack metadata #2548
  • I corrected the f-strings locally and built a local wheel for ART-Core, which was then installed
  • I repeated the testing to assert that the metadata returned correctly uses the f-string substitution
>>> attack_noparallel = AutoAttack(estimator=ptc, attacks=attacks, targeted=True, parallel_pool_size = 0)
>>> attack_parallel = AutoAttack(estimator=ptc, attacks=attacks, targeted=True, parallel_pool_size = pool)
>>>
>>>
>>> no_parallel_adv = attack_noparallel.generate(x=x_train, y=y_train)
>>> parallel_adv = attack_parallel.generate(x=x_train, y=y_train)
>>> print(repr(attack_noparallel))
AutoAttack(targeted=True, parallel_pool_size=0, num_attacks=1)
BestAttacks:
image 1: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 2: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 3: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 4: n/a
image 5: n/a
image 6: n/a
image 7: n/a
image 8: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 9: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 10: n/a
>>>
>>>
>>> print(repr(attack_parallel))
AutoAttack(targeted=True, parallel_pool_size=15, num_attacks=10)
BestAttacks:
image 1: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 2: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 3: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 4: n/a
image 5: n/a
image 6: n/a
image 7: n/a
image 8: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 9: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 10: n/a
>>>

Test Configuration:
OS = Ubuntu 22.04.4 LTS
Python version = 3.11
ART version or commit number = 1.19.0
PyTorch version = 2.3.1

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • My changes have been tested using both CPU and GPU devices

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.40%. Comparing base (27e4c81) to head (c3eb480).
Report is 2 commits behind head on dev_1.19.1.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff               @@
##           dev_1.19.1    #2550      +/-   ##
==============================================
- Coverage       85.41%   85.40%   -0.02%     
==============================================
  Files             334      334              
  Lines           31001    31001              
  Branches         5300     5300              
==============================================
- Hits            26481    26476       -5     
- Misses           3053     3056       +3     
- Partials         1467     1469       +2     
Files with missing lines Coverage Δ
art/attacks/evasion/auto_attack.py 86.15% <ø> (ø)

... and 3 files with indirect coverage changes

@beat-buesser beat-buesser self-requested a review January 7, 2025 15:47
@beat-buesser beat-buesser self-assigned this Jan 7, 2025
@beat-buesser beat-buesser added bug Something isn't working improvement Improve implementation labels Jan 7, 2025
@beat-buesser beat-buesser added this to the ART 1.19.1 milestone Jan 7, 2025
@beat-buesser beat-buesser changed the base branch from main to dev_1.19.1 January 9, 2025 12:41
Copy link
Collaborator

@beat-buesser beat-buesser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lockwoodar Thank you very much for reporting and fixing this bug!

@beat-buesser beat-buesser merged commit 77822b6 into Trusted-AI:dev_1.19.1 Jan 9, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working improvement Improve implementation
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Erroneous literal string in AutoAttack metadata
2 participants